﻿{extend name="public:base" /}

{block name="content"}

<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-lg-12">
            <div class="ibox ">
                <div class="ibox-content">
                    <form method="post">
                        <div class="box-item">
                            <div class="form-group row"><label class="col-sm-1 col-form-label">就医陪诊</label>
                                <div class="col-sm-6">
                                    <input type="file" id="one_img_file" accept="image/*" style="display: none">
                                    <input type="hidden" class="hidden_value" name="img" id="one_img" value="{$config[0]['img'] != '' && $config[0]['img'] != 'img' ? $config[0]['img'] : ''}"/>
                                    <div class="btn btn-w-m btn-primary" onclick="uploadImage('one_img_file', 'one_img', 'one-form-uploaded-box-single', false, 1)">原图上传</div>
                                    <div class="btn btn-w-m btn-primary" onclick="openCrop('one-form-uploaded-box-single', 1)">裁剪上传</div>

                                    <div class="form-uploaded-box" id="one-form-uploaded-box-single" style="width: 140px">
                                        {if $config[0]['img'] != '' && $config[0]['img'] != 'img'}
                                        <div class="form-uploaded-img-box">
                                            <img class="form-uploaded-box-img" src="{$config[0]['img'] != '' && $config[0]['img'] != 'img' ? $config[0]['img'] : ''}">
                                            <i class="form-uploaded-img-preview iconfont icon-yulan" onclick="previewImg(this, 'form-uploaded-img-preview')"></i>
                                            <i class="form-uploaded-img-del iconfont icon-close" onclick="delImage(this, 'cropper_uploaded_img_ids', 'cropper_uploaded_img_paths', 'form-')"></i>
                                        </div>
                                        {/if}
                                    </div>
                                </div>
                            </div>
                            <div class="form-group row"><label class="col-sm-1 col-form-label"></label>
                                <div class="col-sm-1">

                                    <select class="form-control type-select" data-index="0">
                                        <option value="1" {$config[0]['type'] == 1 ? 'selected' : ''}>服务</option>
                                        <option value="2" {$config[0]['type'] == 2 ? 'selected' : ''}>文章</option>
                                    </select>
                                </div>
                                <div class="col-sm-3 service-select service-select-box">
                                    <div style="display: flex;">
                                        <select class="form-control service-type-select" data-index="0">
                                            {volist name="service_list" id="vo"}
                                            <option value="{$vo.id}" {$vo.id == $config[0]['service_type_select_value'] ? 'selected' : ''}>{$vo.name}</option>
                                            {/volist}
                                        </select>

                                        <select class="form-control go_id" style="margin-left: 10px;">

                                        </select>
                                    </div>
                                </div>
                                <div class="col-sm-3 article-select-box">
                                    <div style="display: flex;">
                                        <select class="form-control article-type-select article_type_id" data-index="0">
                                            {volist name="article_list" id="vo"}
                                            <option value="{$vo.id}" {$vo.id == $config[0]['article_id'] ? 'selected' : ''}>{$vo.name}</option>
                                            {/volist}
                                        </select>
                                    </div>
                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>
                        </div>

                        <div class="box-item">
                            <div class="form-group row"><label class="col-sm-1 col-form-label">辅助就医</label>
                                <div class="col-sm-6">
                                    <input type="file" id="two_img_file" accept="image/*" style="display: none">
                                    <input type="hidden" class="hidden_value" name="img" id="two_img" value="{$config[1]['img'] != '' && $config[1]['img'] != 'img' ? $config[1]['img'] : ''}"/>
                                    <div class="btn btn-w-m btn-primary" onclick="uploadImage('two_img_file', 'two_img', 'two-form-uploaded-box-single', false, 1)">原图上传</div>
                                    <div class="btn btn-w-m btn-primary" onclick="openCrop('two-form-uploaded-box-single', 1)">裁剪上传</div>

                                    <div class="form-uploaded-box" id="two-form-uploaded-box-single" style="width: 140px">
                                        {if $config[1]['img'] != '' && $config[1]['img'] != 'img'}
                                        <div class="form-uploaded-img-box">
                                            <img class="form-uploaded-box-img" src="{$config[1]['img'] != '' && $config[1]['img'] != 'img' ? $config[1]['img'] : ''}" data-type="2">
                                            <i class="form-uploaded-img-preview iconfont icon-yulan" onclick="previewImg(this, 'form-uploaded-img-preview')"></i>
                                            <i class="form-uploaded-img-del iconfont icon-close" onclick="delImage(this, 'cropper_uploaded_img_ids', 'cropper_uploaded_img_paths', 'form-')"></i>
                                        </div>
                                        {/if}
                                    </div>
                                </div>
                            </div>
                            <div class="form-group row"><label class="col-sm-1 col-form-label"></label>
                                <div class="col-sm-1">
                                    <select class="form-control type-select" data-index="1">
                                        <option value="1" {$config[1]['type'] == 1 ? 'selected' : ''}>服务</option>
                                        <option value="2" {$config[1]['type'] == 2 ? 'selected' : ''}>文章</option>
                                    </select>
                                </div>
                                <div class="col-sm-3 service-select service-select-box">
                                    <div style="display: flex;">
                                        <select class="form-control service-type-select" data-index="1">
                                            {volist name="service_list" id="vo"}
                                            <option value="{$vo.id}" {$vo.id == $config[1]['service_type_select_value'] ? 'selected' : ''}>{$vo.name}</option>
                                            {/volist}
                                        </select>

                                        <select class="form-control go_id" style="margin-left: 10px;">
                                        </select>
                                    </div>
                                </div>
                                <div class="col-sm-3 article-select-box" style="display: none;">
                                    <select class="form-control article-type-select article_type_id" data-index="1">
                                        {volist name="article_list" id="vo"}
                                        <option value="{$vo.id}" {$vo.id == $config[1]['article_id'] ? 'selected' : ''}>{$vo.name}</option>
                                        {/volist}
                                    </select>
                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>
                        </div>

                        <div class="box-item">
                            <div class="form-group row"><label class="col-sm-1 col-form-label">诊前咨询</label>
                                <div class="col-sm-6">
                                    <input type="file" id="three_img_file" accept="image/*" style="display: none">
                                    <input type="hidden" class="hidden_value" name="img" id="three_img" value="{$config[2]['img'] != '' && $config[2]['img'] != 'img' ? $config[2]['img'] : ''}"/>
                                    <div class="btn btn-w-m btn-primary" onclick="uploadImage('three_img_file', 'three_img', 'three-form-uploaded-box-single', false, 1)">原图上传</div>
                                    <div class="btn btn-w-m btn-primary" onclick="openCrop('three-form-uploaded-box-single', 1)">裁剪上传</div>

                                    <div class="form-uploaded-box" id="three-form-uploaded-box-single" style="width: 140px">
                                        {if $config[2]['img'] != '' && $config[2]['img'] != 'img'}
                                        <div class="form-uploaded-img-box">
                                            <img class="form-uploaded-box-img" src="{$config[2]['img'] != '' && $config[2]['img'] != 'img' ? $config[2]['img'] : ''}" data-type="3">
                                            <i class="form-uploaded-img-preview iconfont icon-yulan" onclick="previewImg(this, 'form-uploaded-img-preview')"></i>
                                            <i class="form-uploaded-img-del iconfont icon-close" onclick="delImage(this, 'cropper_uploaded_img_ids', 'cropper_uploaded_img_paths', 'form-')"></i>
                                        </div>
                                        {/if}
                                    </div>
                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>
                        </div>

                        <div class="box-item">
                            <div class="form-group row"><label class="col-sm-1 col-form-label">代办问诊</label>
                                <div class="col-sm-6">
                                    <input type="file" id="four_img_file" accept="image/*" style="display: none">
                                    <input type="hidden" class="hidden_value" name="img" id="four_img" value="{$config[3]['img'] != '' && $config[3]['img'] != 'img' ? $config[3]['img'] : ''}"/>
                                    <div class="btn btn-w-m btn-primary" onclick="uploadImage('four_img_file', 'four_img', 'four-form-uploaded-box-single', false, 1)">原图上传</div>
                                    <div class="btn btn-w-m btn-primary" onclick="openCrop('four-form-uploaded-box-single', 1)">裁剪上传</div>

                                    <div class="form-uploaded-box" id="four-form-uploaded-box-single" style="width: 140px">
                                        {if $config[3].img != '' && $config[3].img != 'img'}
                                        <div class="form-uploaded-img-box">
                                            <img class="form-uploaded-box-img" src="{$config[3]['img'] != '' && $config[3]['img'] != 'img' ? $config[3]['img'] : ''}" data-type="4">
                                            <i class="form-uploaded-img-preview iconfont icon-yulan" onclick="previewImg(this, 'form-uploaded-img-preview')"></i>
                                            <i class="form-uploaded-img-del iconfont icon-close" onclick="delImage(this, 'cropper_uploaded_img_ids', 'cropper_uploaded_img_paths', 'form-')"></i>
                                        </div>
                                        {/if}
                                    </div>
                                </div>
                            </div>
                            <div class="form-group row"><label class="col-sm-1 col-form-label"></label>
                                <div class="col-sm-1">
                                    <select class="form-control type-select" data-index="2">
                                        <option value="1" {$config[3]['type'] == 1 ? 'selected' : ''}>服务</option>
                                        <option value="2" {$config[3]['type'] == 2 ? 'selected' : ''}>文章</option>
                                    </select>
                                </div>
                                <div class="col-sm-3 service-select service-select-box">
                                    <div style="display: flex;">
                                        <select class="form-control service-type-select" data-index="2">
                                            {volist name="service_list" id="vo"}
                                            <option value="{$vo.id}" {$vo.id == $config[3]['service_type_select_value'] ? 'selected' : ''}>{$vo.name}</option>
                                            {/volist}
                                        </select>

                                        <select class="form-control go_id" style="margin-left: 10px;">
                                        </select>
                                    </div>
                                </div>
                                <div class="col-sm-3 article-select-box">
                                    <select class="form-control article-type-select article_type_id" data-index="2">
                                        {volist name="article_list" id="vo"}
                                        <option value="{$vo.id}" {$vo.id == $config[3]['article_id'] ? 'selected' : ''}>{$vo.name}</option>
                                        {/volist}
                                    </select>
                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>
                        </div>

                        <div class="box-item">
                            <div class="form-group row"><label class="col-sm-1 col-form-label">代办买药</label>
                                <div class="col-sm-6">
                                    <input type="file" id="five_img_file" accept="image/*" style="display: none">
                                    <input type="hidden" class="hidden_value" name="img" id="five_img" value="{$config[4]['img'] != '' && $config[4]['img'] != 'img' ? $config[4]['img'] : ''}"/>
                                    <div class="btn btn-w-m btn-primary" onclick="uploadImage('five_img_file', 'five_img', 'five-form-uploaded-box-single', false, 1)">原图上传</div>
                                    <div class="btn btn-w-m btn-primary" onclick="openCrop('five-form-uploaded-box-single', 1)">裁剪上传</div>

                                    <div class="form-uploaded-box" id="five-form-uploaded-box-single" style="width: 140px">
                                        {if $config[4]['img'] != '' && $config[4]['img'] != 'img'}
                                        <div class="form-uploaded-img-box">
                                            <img class="form-uploaded-box-img" src="{$config[4]['img'] != '' && $config[4]['img'] != 'img' ? $config[4]['img'] : ''}" data-type="4">
                                            <i class="form-uploaded-img-preview iconfont icon-yulan" onclick="previewImg(this, 'form-uploaded-img-preview')"></i>
                                            <i class="form-uploaded-img-del iconfont icon-close" onclick="delImage(this, 'cropper_uploaded_img_ids', 'cropper_uploaded_img_paths', 'form-')"></i>
                                        </div>
                                        {/if}
                                    </div>
                                </div>
                            </div>
                            <div class="form-group row"><label class="col-sm-1 col-form-label"></label>
                                <div class="col-sm-1">
                                    <select class="form-control type-select" data-index="3">
                                        <option value="1" {$config[4]['type'] == 1 ? 'selected' : ''}>服务</option>
                                        <option value="2" {$config[4]['type'] == 2 ? 'selected' : ''}>文章</option>
                                    </select>
                                </div>
                                <div class="col-sm-3 service-select service-select-box">
                                    <div style="display: flex;">
                                        <select class="form-control service-type-select" data-index="3">
                                            {volist name="service_list" id="vo"}
                                            <option value="{$vo.id}" {$vo.id == $config[4]['service_type_select_value'] ? 'selected' : ''}>{$vo.name}</option>
                                            {/volist}
                                        </select>

                                        <select class="form-control go_id" style="margin-left: 10px;">
                                        </select>
                                    </div>
                                </div>
                                <div class="col-sm-3 article-select-box" style="display: none;">
                                    <select class="form-control article-type-select article_type_id" data-index="3">
                                        {volist name="article_list" id="vo"}
                                        <option value="{$vo.id}" {$vo.id == $config[4]['article_id'] ? 'selected' : ''}>{$vo.name}</option>
                                        {/volist}
                                    </select>
                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>
                        </div>

                        <div class="box-item">
                            <div class="form-group row"><label class="col-sm-1 col-form-label">送/取服务</label>
                                <div class="col-sm-6">
                                    <input type="file" id="six_img_file" accept="image/*" style="display: none">
                                    <input type="hidden" class="hidden_value" name="img" id="six_img" value="{$config[5]['img'] != '' && $config[5]['img'] != 'img' ? $config[5]['img'] : ''}"/>
                                    <div class="btn btn-w-m btn-primary" onclick="uploadImage('six_img_file', 'six_img', 'six-form-uploaded-box-single', false, 1)">原图上传</div>
                                    <div class="btn btn-w-m btn-primary" onclick="openCrop('six-form-uploaded-box-single', 1)">裁剪上传</div>

                                    <div class="form-uploaded-box" id="six-form-uploaded-box-single" style="width: 140px">
                                        {if $config[5]['img'] != '' && $config[5]['img'] != 'img'}
                                        <div class="form-uploaded-img-box">
                                            <img class="form-uploaded-box-img" src="{$config[5]['img'] != '' && $config[5]['img'] != 'img' ? $config[5]['img'] : ''}" data-type="6">
                                            <i class="form-uploaded-img-preview iconfont icon-yulan" onclick="previewImg(this, 'form-uploaded-img-preview')"></i>
                                            <i class="form-uploaded-img-del iconfont icon-close" onclick="delImage(this, 'cropper_uploaded_img_ids', 'cropper_uploaded_img_paths', 'form-')"></i>
                                        </div>
                                        {/if}
                                    </div>
                                </div>
                            </div>
                            <div class="form-group row"><label class="col-sm-1 col-form-label"></label>
                                <div class="col-sm-1">
                                    <select class="form-control type-select" data-index="4">
                                        <option value="1" {$config[5]['type'] == 1 ? 'selected' : ''}>服务</option>
                                        <option value="2" {$config[5]['type'] == 2 ? 'selected' : ''}>文章</option>
                                    </select>
                                </div>
                                <div class="col-sm-3 service-select service-select-box">
                                    <div style="display: flex;">
                                        <select class="form-control service-type-select" data-index="4">
                                            {volist name="service_list" id="vo"}
                                            <option value="{$vo.id}" {$vo.id == $config[5]['service_type_select_value'] ? 'selected' : ''}>{$vo.name}</option>
                                            {/volist}
                                        </select>

                                        <select class="form-control go_id" style="margin-left: 10px;">
                                        </select>
                                    </div>
                                </div>
                                <div class="col-sm-3 article-select-box">
                                    <select class="form-control article-type-select article_type_id" data-index="4">
                                        {volist name="article_list" id="vo"}
                                        <option value="{$vo.id}" {$vo.id == $config[5]['article_id'] ? 'selected' : ''}>{$vo.name}</option>
                                        {/volist}
                                    </select>
                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>
                        </div>

                        <div class="box-item">
                            <div class="form-group row"><label class="col-sm-1 col-form-label">检查预约</label>
                                <div class="col-sm-6">
                                    <input type="file" id="seven_img_file" accept="image/*" style="display: none">
                                    <input type="hidden" class="hidden_value" name="img" id="seven_img" value="{$config[6]['img'] != '' && $config[6]['img'] != 'img' ? $config[6]['img'] : ''}"/>
                                    <div class="btn btn-w-m btn-primary" onclick="uploadImage('seven_img_file', 'seven_img', 'seven-form-uploaded-box-single', false, 1)">原图上传</div>
                                    <div class="btn btn-w-m btn-primary" onclick="openCrop('seven-form-uploaded-box-single', 1)">裁剪上传</div>

                                    <div class="form-uploaded-box" id="seven-form-uploaded-box-single" style="width: 140px">
                                        {if $config[6]['img'] != '' && $config[6]['img'] != 'img'}
                                        <div class="form-uploaded-img-box">
                                            <img class="form-uploaded-box-img" src="{$config[6]['img'] != '' && $config[6]['img'] != 'img' ? $config[6]['img'] : ''}" data-type="7">
                                            <i class="form-uploaded-img-preview iconfont icon-yulan" onclick="previewImg(this, 'form-uploaded-img-preview')"></i>
                                            <i class="form-uploaded-img-del iconfont icon-close" onclick="delImage(this, 'cropper_uploaded_img_ids', 'cropper_uploaded_img_paths', 'form-')"></i>
                                        </div>
                                        {/if}
                                    </div>
                                </div>
                            </div>
                            <div class="form-group row"><label class="col-sm-1 col-form-label"></label>
                                <div class="col-sm-1">
                                    <select class="form-control type-select" data-index="5">
                                        <option value="1" {$config[6]['type'] == 1 ? 'selected' : ''}>服务</option>
                                        <option value="2" {$config[6]['type'] == 2 ? 'selected' : ''}>文章</option>
                                    </select>
                                </div>
                                <div class="col-sm-3 service-select service-select-box">
                                    <div style="display: flex;">
                                        <select class="form-control service-type-select" data-index="5">
                                            {volist name="service_list" id="vo"}
                                            <option value="{$vo.id}" {$vo.id == $config[6]['service_type_select_value'] ? 'selected' : ''}>{$vo.name}</option>
                                            {/volist}
                                        </select>

                                        <select class="form-control go_id" style="margin-left: 10px;">
                                        </select>
                                    </div>
                                </div>
                                <div class="col-sm-3 article-select-box">
                                    <select class="form-control article-type-select article_type_id" data-index="5">
                                        {volist name="article_list" id="vo"}
                                        <option value="{$vo.id}" {$vo.id == $config[6]['article_id'] ? 'selected' : ''}>{$vo.name}</option>
                                        {/volist}
                                    </select>
                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>
                        </div>

                        <div class="box-item">
                            <div class="form-group row"><label class="col-sm-1 col-form-label">院内服务</label>
                                <div class="col-sm-6">
                                    <input type="file" id="eight_img_file" accept="image/*" style="display: none">
                                    <input type="hidden" class="hidden_value" name="img" id="eight_img" value="{$config[7]['img'] != '' && $config[7]['img'] != 'img' ? $config[7]['img'] : ''}"/>
                                    <div class="btn btn-w-m btn-primary" onclick="uploadImage('eight_img_file', 'eight_img', 'eight-form-uploaded-box-single', false, 1)">原图上传</div>
                                    <div class="btn btn-w-m btn-primary" onclick="openCrop('eight-form-uploaded-box-single', 1)">裁剪上传</div>

                                    <div class="form-uploaded-box" id="eight-form-uploaded-box-single" style="width: 140px">
                                        {if $config[7]['img'] != '' && $config[7]['img'] != 'img'}
                                        <div class="form-uploaded-img-box">
                                            <img class="form-uploaded-box-img" src="{$config[7]['img'] != '' && $config[7]['img'] != 'img' ? $config[7]['img'] : ''}" data-type="8">
                                            <i class="form-uploaded-img-preview iconfont icon-yulan" onclick="previewImg(this, 'form-uploaded-img-preview')"></i>
                                            <i class="form-uploaded-img-del iconfont icon-close" onclick="delImage(this, 'cropper_uploaded_img_ids', 'cropper_uploaded_img_paths', 'form-')"></i>
                                        </div>
                                        {/if}
                                    </div>
                                </div>
                            </div>
                            <div class="form-group row"><label class="col-sm-1 col-form-label"></label>
                                <div class="col-sm-1">
                                    <select class="form-control type-select" data-index="6">
                                        <option value="1" {$config[7]['type'] == 1 ? 'selected' : ''}>服务</option>
                                        <option value="2" {$config[7]['type'] == 2 ? 'selected' : ''}>文章</option>
                                    </select>
                                </div>
                                <div class="col-sm-3 service-select service-select-box">
                                    <div style="display: flex;">
                                        <select class="form-control service-type-select" data-index="6">
                                            {volist name="service_list" id="vo"}
                                            <option value="{$vo.id}" {$vo.id == $config[7]['service_type_select_value'] ? 'selected' : ''}>{$vo.name}</option>
                                            {/volist}
                                        </select>

                                        <select class="form-control go_id" style="margin-left: 10px;">
                                        </select>
                                    </div>
                                </div>
                                <div class="col-sm-3 article-select-box" style="display: none;">
                                    <select class="form-control article-type-select article_type_id" data-index="6">
                                        {volist name="article_list" id="vo"}
                                        <option value="{$vo.id}" {$vo.id == $config[7]['article_id'] ? 'selected' : ''}>{$vo.name}</option>
                                        {/volist}
                                    </select>
                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>
                        </div>

                        <div class="box-item">
                            <div class="form-group row"><label class="col-sm-1 col-form-label">会员订单</label>
                                <div class="col-sm-6">
                                    <input type="file" id="nine_img_file" accept="image/*" style="display: none">
                                    <input type="hidden" class="hidden_value" name="img" id="nine_img" value="{$config[8]['img'] != '' && $config[8]['img'] != 'img' ? $config[8]['img'] : ''}"/>
                                    <div class="btn btn-w-m btn-primary" onclick="uploadImage('nine_img_file', 'nine_img', 'nine-form-uploaded-box-single', false, 1)">原图上传</div>
                                    <div class="btn btn-w-m btn-primary" onclick="openCrop('nine-form-uploaded-box-single', 1)">裁剪上传</div>

                                    <div class="form-uploaded-box" id="nine-form-uploaded-box-single" style="width: 140px">
                                        {if $config[8]['img'] != '' && $config[8]['img'] != 'img'}
                                        <div class="form-uploaded-img-box">
                                            <img class="form-uploaded-box-img" src="{$config[8]['img'] != '' && $config[8]['img'] != 'img' ? $config[8]['img'] : ''}" data-type="9">
                                            <i class="form-uploaded-img-preview iconfont icon-yulan" onclick="previewImg(this, 'form-uploaded-img-preview')"></i>
                                            <i class="form-uploaded-img-del iconfont icon-close" onclick="delImage(this, 'cropper_uploaded_img_ids', 'cropper_uploaded_img_paths', 'form-')"></i>
                                        </div>
                                        {/if}
                                    </div>
                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>
                        </div>

                        <div class="form-group row">
                            <div class="col-sm-4 col-sm-offset-2">
                                <button type="button" class="btn btn-w-m btn-default back-page">返回</button>
                                <button type="button" class="btn btn-w-m btn-primary index-ajax-post">提交</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>

{include file="public/cropper-img-mask" cropper_uploaded_img_ids="cropper_uploaded_img_ids" cropper_uploaded_img_paths="cropper_uploaded_img_paths" crop_preview_box="crop-preview-box" /}{include file="public/preview-img-mask" swiper-id="cropper-preview" /}{/block}

{/block}

{block name="js"}
<script>
    var service_list = `{$service_list_json}` ? JSON.parse(`{$service_list_json}`) : [];
    var config_json = `{$config_json}` ? JSON.parse(`{$config_json}`) : [];

    if(config_json.length > 0){
        config_json.forEach((val, key) => {
            var type = parseInt(val.type);

            if (type == 1) {
                key = key > 2 ? key - 1 : key;

                // 服务
                $('.service-select').eq(key).show();
                $('.article-select-box').eq(key).hide();

                var service_type_select_value = parseInt(val.service_type_select_value);// 服务分类id
                renderServiceSelect(service_list, key, service_type_select_value, val.service_id);
            } else {
                // 文章
                $('.service-select').eq(key).hide();
                $('.article-select-box').eq(key).show();
            }
        })
    }

    $('.type-select').change(function () {
        var type = $(this).val(), index = $(this).data('index'), service_type_id = $('.service-type-select').eq(index).val();
        if (type == 1) {
            // 服务
            $('.service-select').eq(index).show();
            $('.article-select-box').eq(index).hide();

            renderServiceSelect(service_list, index, service_type_id);
        } else {
            // 文章
            $('.service-select').eq(index).hide();
            $('.article-select-box').eq(index).show();
        }
    })

    $('.service-type-select').change(function () {
        var type_id = $(this).val(), index = $(this).data('index');
        renderServiceSelect(service_list, index, type_id);
    })

    function renderServiceSelect(list, index, type_id = 0, service_id = 0) {
        var html = '';
        list.forEach(val => {
            if (type_id == 0) {
                list[0].son_list.forEach(v => {
                    html += `<option value="${v.id}">${v.name}</option>`;
                })
            } else if (val.id == type_id) {
                val.son_list.forEach(v => {
                    var selected = service_id > 0 ? (v.id == service_id ? 'selected' : '') : '';
                    html += `<option value="${v.id}" ${selected}>${v.name}</option>`;
                })
            }
        })
        $('.service-select-box').eq(index).find('.go_id').html(html)
    }

    $('.index-ajax-post').click(function () {
        var data = [
            {img : $('.form-uploaded-box-img').eq(0).attr('src'), type: $('.type-select').eq(0).val(), service_type_select_value: $('.service-type-select').eq(0).val(), service_id: $('.service-select-box').eq(0).find('.go_id').val(), article_id: $('.article-type-select').eq(0).val() },
            {img : $('.form-uploaded-box-img').eq(1).attr('src'), type: $('.type-select').eq(1).val(), service_type_select_value: $('.service-type-select').eq(1).val(), service_id: $('.service-select-box').eq(1).find('.go_id').val(), article_id: $('.article-type-select').eq(1).val() },
            {img : $('.form-uploaded-box-img').eq(2).attr('src'), type: 0, service_type_select_value: 0, service_id: 0, article_id: 0 },
            {img : $('.form-uploaded-box-img').eq(3).attr('src'), type: $('.type-select').eq(2).val(), service_type_select_value: $('.service-type-select').eq(2).val(), service_id: $('.service-select-box').eq(2).find('.go_id').val(), article_id: $('.article-type-select').eq(2).val() },
            {img : $('.form-uploaded-box-img').eq(4).attr('src'), type: $('.type-select').eq(3).val(), service_type_select_value: $('.service-type-select').eq(3).val(), service_id: $('.service-select-box').eq(3).find('.go_id').val(), article_id: $('.article-type-select').eq(3).val() },
            {img : $('.form-uploaded-box-img').eq(5).attr('src'), type: $('.type-select').eq(4).val(), service_type_select_value: $('.service-type-select').eq(4).val(), service_id: $('.service-select-box').eq(4).find('.go_id').val(), article_id: $('.article-type-select').eq(4).val() },
            {img : $('.form-uploaded-box-img').eq(6).attr('src'), type: $('.type-select').eq(5).val(), service_type_select_value: $('.service-type-select').eq(5).val(), service_id: $('.service-select-box').eq(5).find('.go_id').val(), article_id: $('.article-type-select').eq(5).val() },
            {img : $('.form-uploaded-box-img').eq(7).attr('src'), type: $('.type-select').eq(6).val(), service_type_select_value: $('.service-type-select').eq(6).val(), service_id: $('.service-select-box').eq(6).find('.go_id').val(), article_id: $('.article-type-select').eq(6).val() },
            {img : $('.form-uploaded-box-img').eq(8).attr('src'), type: 0, service_type_select_value: 0, service_id: 0, article_id: 0 }
        ];
        data = JSON.stringify(data);

        $.post('/admin/manage/indexConfig', {data}, res => {
            if(res.result == 1) {
                layer.msg(res.msg, {icon: 1, time: 1000})
            }else{
                layer.msg(res.msg, {icon: 2, time: 1000})
            }
        },'json')

    })


</script>{/block}